#include<iostream>
using namespace std;

#define SIZE 8

bool QueenConflict(int row, int col, int* queen)
{
    for (int i = 0; i < row; i++)
    {
        if ((queen[i] == col)
            || (queen[i] + i == row + col)
            || (i - queen[i] == row - col))
        {
            return true;
        }
    }
    
    return false;
}

void PrintQueen(int* queen)
{
    cout<< "Queen Order:\n";
    for (int i = 0; i < SIZE; i++)
    {
        for (int j = 0; j < SIZE; j++)
        {
            cout<< (queen[i] == j ? 'x' : '-');
        }
        cout<<"\n";
    }
}

void Queen(int i, int* queen)
{
    for (int j = 0; j < SIZE; j++)
    {
        if (!QueenConflict(i, j, queen))
        {
            queen[i] = j;
            if (i == SIZE - 1)
            {
                PrintQueen(queen);
            }
            else
            {
                Queen(i + 1, queen);
            }
        }
    }
}

int main()
{
    int queen[SIZE] = {0};
    Queen(0, queen);

    system("pause");
}

